//
//  CinemaTableViewCell.m
//  豆瓣电影
//
//  Created by dllo on 16/6/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CinemaTableViewCell.h"
#import "CinemaModel.h"
#import "GetHeightTools.h"

@interface CinemaTableViewCell()

@property (nonatomic, retain) UILabel *cinemaName;

@property (nonatomic, retain) UILabel *telephone;

@property (nonatomic, retain) UILabel *address;

@property (nonatomic, retain) UIImageView *backImageView;

@end

@implementation CinemaTableViewCell

-(void)dealloc
{
    [_backImageView release];
    [_cinemaModel release];
    [_address release];
    [_telephone release];
    [_cinemaName release];
    
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.backImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bg_eventlistcell@2x.png"]];
        [self.contentView addSubview:self.backImageView];
        [self.backImageView release];
        
        self.telephone = [[UILabel alloc]init];
        [self.backImageView addSubview:self.telephone];
        [self.telephone release];
        
        self.address = [[UILabel alloc]init];
        [self.backImageView addSubview:self.address];
        self.address.numberOfLines = 0;
        [self.address release];
        
        self.cinemaName = [[UILabel alloc]init];
        [self.backImageView addSubview:self.cinemaName];
        [self.cinemaName release];
        
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.backImageView.frame = CGRectMake(10, 10, CGRectGetWidth(self.bounds) - 17, CGRectGetHeight(self.bounds) - 10);
    
    self.cinemaName.frame = CGRectMake(10, 10, self.backImageView.frame.size.width, 30);
    self.cinemaName.font = [UIFont systemFontOfSize:25];
    
    CGFloat addressHeight = [GetHeightTools heightWithText:self.cinemaModel.address];
    self.address.frame = CGRectMake(10, 50, CGRectGetWidth(self.bounds) - 30, addressHeight);
    
    
    self.telephone.frame = CGRectMake(10, self.backImageView.frame.size.height * 0.8, self.backImageView.frame.size.width, 25);
    
}


-(void)setCinemaModel:(CinemaModel *)cinemaModel
{
    if (_cinemaModel != cinemaModel) {
        [_cinemaModel release];
        _cinemaModel = [cinemaModel retain];
    }

    self.cinemaName.text = cinemaModel.cinemaName;
    
    self.telephone.text = cinemaModel.telephone;
    
    self.address.text = cinemaModel.address;
    
}


@end











